



//
//  CheckViewController.m
//  nncloud
//
//  Created by macfeel on 2019/7/10.
//  Copyright © 2019 macfai. All rights reserved.
//

#import "CheckViewController.h"
#import "CheckModifyViewController.h"
@interface CheckViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (nonatomic,strong)NSArray *titleArray;
@property (nonatomic,strong)NSArray *detailArray;

@end

@implementation CheckViewController

#define cellIdentifier  @"cellId"

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = false;
}

-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = YES;
    
}

-(UITableView *)tableView{
    
    if (!_tableView) {
//        WeakStament(ws);
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight -NavBarHeight) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 50.f;
        //        _tableView.separatorColor = [UIColor clearColor];
        _tableView.backgroundColor = kBackgroundColor;

        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationItem setItemWithTitle:@"设备核对" textColor:kNavigationTitleColor fontSize:18 itemType:center];
//    [self showNoDataImageView:@"none" withTitle:@"暂无数据哦"];
    
    self.titleArray = @[@"设备编号",@"型号",@"站名",@"位置",@"出厂日期",@"生产厂家",@"出所日期",@"到期日期",@"周期",];
    self.detailArray = @[@"",@"",@"长春",@"9-2-3-4",@"2018-3-3",@"沈阳信号厂",@"2018-3-6",@"2028-3-6",@"15",];
    
    [self.view addSubview:self.tableView];
    
    [self addFooterView];
    // Do any additional setup after loading the view.
}

-(void)addFooterView{
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
    UIButton *left = [UIButton buttonWithType:UIButtonTypeCustom];
    left.backgroundColor = kLightGrayColor;
    [left setTitle:@"核对无误提交" forState:UIControlStateNormal];
    [left addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    left.tag = 1001;
    left.frame = CGRectMake(0, 0, ScreenWidth/2, 50);
    [bgView addSubview:left];
    
    UIButton *right = [UIButton buttonWithType:UIButtonTypeCustom];
    right.backgroundColor = ThemeBlue;
    [right addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    right.tag = 1002;
    [right setTitle:@"核对有误修改" forState:UIControlStateNormal];
    right.frame = CGRectMake(ScreenWidth/2, 0, ScreenWidth/2, 50);
    [bgView addSubview:right];
    
    self.tableView.tableFooterView = bgView;
}


-(void)btnAction:(UIButton *)btn{
    if (btn.tag==1001) {
        ///左边
        [SVProgressHUD show];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [SVProgressHUD dismiss];
            [AFToast showText:@"提交成功"];
            [self.navigationController popViewControllerAnimated:YES];
        });
    }else{
        ///右边
        CheckModifyViewController *modify = [CheckModifyViewController new];
        [self.navigationController pushViewController:modify animated:YES];
    }
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titleArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ///detail 不显示
    //    NSDictionary *dict = self.dict;
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    // Configure the cell...
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1
                                      reuseIdentifier: cellIdentifier];
    }
    cell.selectionStyle = 0;
    cell.textLabel.textColor = kDarkGrayColor;
//    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text = self.titleArray[indexPath.row];
    cell.detailTextLabel.text = self.detailArray[indexPath.row];
    return cell;
}


@end
